# -*- mode: python; coding: utf-8; -*-
##--------------------------------------------------------------------------##
##
## Copyright (C) 1998-2003 Markus Oberhumer <markus@oberhumer.com>
## Copyright (C) 2003 Mt. Hood Playing Card Co.
## Copyright (C) 2005-2010 Skomoroh <skomoroh@users.sourceforge.net>
## Copyright (C) 2010-2013 Jeremy Austin-Bardo <tjaustinbardo@gmail.com>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##--------------------------------------------------------------------------##
__docformat__ = "restructuredtext en"

from .. import autostacks
from .. import pilelib as stack
from .. import stackfill as fill
from ..gamelib import info as gi, state, game
from ..packlib import info as cs, place
from ..forms import fortythieves as FortyThievesLayout
from ..forms import klondike as KlondikeLayout
from ..piles import (foundation as FoundationStack, numerica as NumericaStack,
                     talon as TalonStack,)
from ..utillib.misc import kwdefault

Wrap = stack.StackWrapper
GT, SL = gi.GT, gi.SL
SHORT_A7Q = cs.SHORT_A7K[:-1]


class TamOShanter(game.Game):
    """
    Finish 1 deck on foundation dealing 1 card per 4 row.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [4 horz S foundation, vert offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.DealRowTalon
        Deal 1 card per row. No redeal.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stack.RK_Foundation
        Build up in rank alone. Play top. Base ACE.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x3831c, name='Tam OʼShanter', game_type=GT.NUMERICA,
                    decks=1, skill_level=SL.LUCK, version='4.20')
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    _layout_ = KlondikeLayout.KlondikeLayout
    _talon_ = stack.DealRowTalon
    _foundation_ = stack.RK_Foundation
    _row_ = stack.BasicRowStack

    def _create_game(self, **kw):
        """
        _create_game([rows=4, playcards=12, texts=True]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.klondike` for keyword definitions.
        """
        kwdefault(rows=4, playcards=12, texts=True)
        return super(TamOShanter, self)._create_game(**kw)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 1 ea.

        .. \_start() -> None
        """
        self.s['talon'].dealRow()

    def _autopiles(self, event=None):
        """
        Return piles for auto or quick move.

        Overide to disable autoflip, autodrop.

        .. \_autopiles(self, event=None) -> seq(seq(Pile ...), seq(Pile ...),
             seq(Pile ...))
        """
        return autostacks.quickplay(super(TamOShanter, self)._autopiles(event))


class Amazons(TamOShanter):
    """
    Finish 1 short deck on foundation dealing 1 card per 4 row, playing
    only to neighbor foundation except last on any.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [4 horz S foundation, vert offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stacks.talon.Amazons_Talon (max_rounds=INFINITE)
        Deal 1 card per row with neighbor foundation gap. Redeal reset row.
        Inifinite redeal.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stacks.foundation.Amazons_Foundation
        Build up in rank alone from neighbor row except last on any. Play top.
        Base ace.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.

    :seealso:
      <http://en.wikipedia.org/wiki/Amazons_%28solitaire%29>
    """
    __info__ = dict(id=0x38406, name='Amazons', game_type=GT.NUMERICA,
                    decks=1, redeals=cs.INFINITE, skill_level=SL.LUCK,
                    ranks=SHORT_A7Q, version='0.90fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = Wrap(TalonStack.Amazons_Talon, max_rounds=cs.INFINITE)
    _foundation_ = FoundationStack.Amazons_Foundation


class AuldLangSyne(TamOShanter):
    """
    Finish 1 deck on foundation dealing 1 card per 4 row with ace per
    foundation.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [4 horz S foundation, vert offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.DealRowTalon
        Deal 1 card per row. No redeal.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stack.RK_Foundation
        Init ace per. Build up in rank alone. Play top. Base ace.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x382cf, name='Auld Lang Syne', game_type=(GT.NUMERICA
                    | GT.GNOME), decks=1, skill_level=SL.LUCK, version='3.00',
                    altnames=('Patience',))
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    def _pack_place(self, cards):
        """
        _pack_place(cards:seq(Card ...)) -> seq(Card ...)

        Overide to return ACE on top by suit, deck for _foundation_ deal.
        """
        return place.MoveToTop(cards, place.AllAce)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[foundations] 1 ea.
          - s[rows] 1 ea.

        .. \_start() -> None
        """
        self.s['talon'].dealRow(rows=self.s['foundations'], frames=0)
        return super(AuldLangSyne, self)._start(self, **kw)


class Formic(AuldLangSyne):
    """
    Finish 1 deck on foundation dealing 1 card per 4 row with all of 1
    rank per foundation.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [4 horz S foundation, vert offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.DealRowTalon
        Deal 1 card per row. No redeal.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stacks.foundation.Formic_Foundation (max_cards=52,
          max_move=0)
        Init anyone rank per. Build either in rank alone. Play none. Base 1st.
        Max 52 cards.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x38520, name='Formic', game_type=GT.NUMERICA, decks=1,
                    skill_level=SL.MOSTLY_SKILL, version='0.94fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _foundation_ = Wrap(FoundationStack.Formic_Foundation, max_cards=52,
                        max_move=0)

    def _pack_place(self, cards):
        """
        _pack_place(cards:seq(Card ...)) -> seq(Card ...)

        Overide to return any 1 rank on top by suit, deck for _foundation_ deal.
        """
        return place.MoveToTop(cards, place.AnyOneRank)


class Acquaintance(AuldLangSyne):
    """
    Finish 1 deck on foundation dealing 1 card per 4 row with ace per
    foundation and redeal of row.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [4 horz S foundation, no offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.DealRowRedealTalon (max_rounds=3)
        Deal 1 card per row. Redeal per row. 3 redeals.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stack.RK_Foundation
        Init ace per. Build up in rank alone. Play top. Base ace.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x3845a, name='Acquaintance', game_type=GT.NUMERICA,
                    decks=1, redeals=2, skill_level=SL.BALANCED,
                    version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = Wrap(stack.DealRowRedealTalon, max_rounds=3)


class DoubleAcquaintance(Acquaintance):
    """
    Finish 1 deck on foundation dealing 1 card per 8 row with ace per
    foundation and redeal of row.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [8 horz S foundation,no offset]
        - talon [1 NW, no offset]
        - foundation [8 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.DealRowRedealTalon (max_rounds=3)
        Deal 1 card per row. Redeal per row. 3 redeals.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stack.RK_Foundation
        Init ace per. Build up in rank alone. Play top. Base ace.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x384a0, name='Double Acquaintance',
                    game_type=GT.NUMERICA, decks=2, redeals=2,
                    skill_level=SL.BALANCED, altnames=(
                    'Acquaintance (2 Decks)',), version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    def _create_game(self, **kw):
        """
        _create_game([rows=8]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.klondike` for keyword definitions.
        """
        kw.setdefault(rows=8)
        return super(DoubleAcquaintance, self)._create_game(self, **kw)


class Scuffle(AuldLangSyne):
    """
    Finish 1 deck on foundation dealing 1 card per 4 row with ace per
    foundation and shuffle and redeal of row.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [4 horz S foundation, no offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stacks.talon.Scuffle_Talon (max_rounds=3)
        Deal 1 card per row. Shuffle before each redeal per row. 3
        redeals.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stack.RK_Foundation
        Init ace per. Build up in rank alone. Play top. Base ace.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x38499, name='Scuffle', game_type=(GT.NUMERICA |
                    GT.GNOME), decks=1, redeals=2, skill_level=SL.MOSTLY_LUCK,
                    version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = Wrap(TalonStack.Scuffle_Talon, max_rounds=3)

    def _create_game(self, **kw):
        """
        _create_game([playcards=0]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.klondike` for keyword definitions.
        """
        kw.setdefault('playcards', 0)
        return super(Scuffle, self)._create_game(self, **kw)


class Strategy(game.Game):
    """
    Finish 1 deck on foundation dealing 1 card per 8 row with ace per
    foundation and open talon.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [8 horz S foundation, vert offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.OpenTalon
        Build none. Play top on row. No redeal.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stacks.foundation.Strategy_Foundation (max_move=0)
        Init ace per. Build up in rank by same suit after talon gap. Play
        none. Base ace.

      _row_ : pysollib.stack.Stack
        .. pysollib..stacks.numerica.Strategy_RowStack
        Init 1 card per. Build any from talon. Play top after talon gap.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.stacks.numerica.Hint
    """
    __info__ = dict(id=0x3831d, name='Strategy', game_type=GT.NUMERICA,
                    decks=1, skill_level=SL.SKILL, version='4.20')
    __author__ = 'Markus Oberhumer'
    __credits__ = ['Albert Morehead', 'Geoffrey Mott-Smith']
    __version__ = '7.70'

    _layout_ = KlondikeLayout.KlondikeLayout
    _talon_ = stack.OpenTalon
    _foundation_ = Wrap(FoundationStack.Strategy_Foundation, max_move=0)
    _row_ = NumericaStack.Strategy_RowStack
    _hint_ = NumericaStack.Hint

    def _create_game(self, **kw):
        """
        _create_game([rows=8, playcards=12]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.klondike` for keyword definitions.
        """
        kwdefault(kw, rows=8, playcards=12)
        return super(Strategy, **kw)._create_game(**kw)

    def _pack_place(self, cards):
        """
        _pack_place(cards:seq(Card ...)) -> seq(Card ...)

        Overide to return ACE on top by suit, deck for _foundation_ deal.
        """
        return place.MoveToTop(cards, place.AllAce)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[foundations] 1 ea.
          - s[talon] top up.

        .. \_start() -> None
        """
        self.s['talon'].dealRow(rows=self.s['foundations'])
        self.s['talon'].fill_stack()


class StrategyPlus(Strategy):
    """
    Finish 1 deck on foundation using 8 RowStack and open Talon which finish
    ace.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.klondike.KlondikeLayout
        - row [6 horz S foundation, vert offset]
        - talon [1 NW, no offset]
        - foundation [4 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.OpenTalon
        Build none. Play top on row. No redeal. Auto finish ace.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stacks.foundation.Strategy_Foundation (max_move=0)
        Build up in rank by same suit after talon gap. Play none. Base
        ace.

      _row_ : pysollib.stack.Stack
        .. pysollib.stacks.numerica.Strategy_RowStack
        Build any from talon. Play top after talon gap.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.stacks.numerica.Hint
    """
    __info__ = dict(id=0x384ec, name='Strategy +', game_type=GT.NUMERICA,
                    decks=1, skill_level=SL.SKILL, version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    def _create_game(self, **kw):
        """
        _create_game([rows=6]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.klondike` for keyword definitions.
        """
        kw.setdefault('rows', 6)
        return super(StrategyPlus, self)._create_game(self, **kw)

    def _pack_place(self, cards):
        """
        _pack_place(cards:seq(Card ...)) -> seq(Card ...)

        Overide to return cards unchanged.
        """
        return cards

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[talon] top up.

        .. \_start() -> None
        """
        self.s['talon'].fill_stack()

    @state.move_state('fill')
    def _auto_fill(self, stack):
        """
        After any play from talon, move top if ace to foundation.

        *Parameters*:
          stack : pysollib.stack.Stack
            Pile just played.

        *requires*:
          `pysollib.stackfill.TalonFinishAce` to auto finish top ace.
        """
        fill.TalonFinishAce(self, stack)


class Interregnum(game.Game):
    """
    Finish 2 deck on foundation dealing 1 card per 8 row with foundation base
    rank set +1 of neighbor reseve dealt.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.fortythieves.PrimroseLayout
        - row [8 horz S foundation, vert offset]
        - talon [1 SE, no offset]
        - foundation [8 horz S reserve, no offset]
        - reserve [8 horz N, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.DealRowTalon
        Deal 1 card per row. No redeal.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.stacks.foundation.Interregnum_Foundation (mod=13,
          max_move=0)
        Build up in rank alone wrap. Play none. Base rank +1 top neighbor
        reserve.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _reserve_ : pysollib.stack.Stack
        .. pysollib.stack.OpenStack
        Init 1 card per. Build none. Play top as as last on neighbor
        foundation.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x382eb, name='Interregnum', game_type=GT.NUMERICA,
                    decks=2, skill_level=SL.BALANCED, version='3.10')
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    _layout_ = FortyThievesLayout.PrimroseLayout
    _talon_ = stack.DealRowTalon
    _foundation_ = Wrap(FoundationStack.Interregnum_Foundation, mod=13,
                        max_move=0)
    _row_ = stack.BasicRowStack
    _reserve_ = stack.OpenStack

    def _create_game(self, **kw):
        """
        _create_game([rows=8, reserves=8, playcards=12]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.primrose` for keyword definitions.
        """
        kwdefault(kw, rows=8, reserves=8, playcards=12)
        return super(Interregnum, self)._create_game(**kw)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 1 ea.
          - s[reserves]: 1 ea. save neighbor foundation caps + 1 % 13

        .. \_start() -> None

        *Raises:*
          Assertion Error: len foundations not len reserves
        """
        assert len(self.s['foundations']) == len(self.s['reserves'])
        self.s['talon'].dealRow()
        self.s['talon'].dealRow(rows=self.s['reserves'])
        for pile, card in zip(self.s['foundations'],
                              [r.BASECARD for r in self.s['reserves']]):
            self._save_stack_caps(pile, base_rank=(card['rank'] + 1) % 13)

    def _autopiles(self, event=None):
        """
        Return piles for auto or quick move.

        Overide to disable autoflip, autodrop.

        .. \_autopiles(self, event=None) -> seq(seq(Pile ...), seq(Pile ...),
             seq(Pile ...))
        """
        return autostacks.quickplay(super(Interregnum, self)._autopiles(event))


class Primrose(Interregnum):
    """
    Finish 2 deck on foundation dealing 1 card per 8 row with foundation base
    rank set +1 of neighbor reserve dealt and redeal 1 row pile per.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.primrose.PrimroseLayout
        - row [8 horz S foundation, vert offset]
        - talon [1 SE, no offset]
        - foundation [8 horz S reserve, no offset]
        - reserve [8 horz N, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stacks.talon.Primrose_Talon (max_rounds=9)
        Redeal 1 row pile per redeal. 9 redeals.

      _foundation_ : pysollib.stack.Stack
        .. foundation.Interregnum_Foundation (mod=13, max_move=0)
        Build up in rank alone wrap. Play none. Base rank +1 top neighbor
        reserve.

      _row_ : pysollib.stack.Stack
        .. pysollib.stack.BasicRowStack
        Init 1 card per. Build none. Play top.

      _reserve_ : pysollib.stack.Stack
        .. pysollib.stack.OpenStack
        Init 1 card per. Build none. Play top as as last on neighbor
        foundation.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :note:
      ⟪autoflip⟫, ⟪autodrop⟫ disabled.
    """
    __info__ = dict(id=0x384a9, name='Primrose', game_type=GT.NUMERICA,
                    decks=2, redeals=8, skill_level=SL.BALANCED,
                    version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = Wrap(TalonStack.Primrose_Talon, max_rounds=9)

    def _create_game(self, **kw):
        """
        _create_game([playcards=16]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.primrose` for keyword definitions.
        """
        kw.setdefault('playcards', 16)
        return Interregnum._create_game(self, **kw)

    def _start(self, rows=12, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 12 ea up.
          - s[reserves]: 1 ea. save neighbor foundation caps + 1 % 13

        .. \_start() -> None

        *Raises:*
          Assertion Error: len foundations not len reserves
        """
        for i in range(rows - 1):
            self.s['talon'].dealRow(frames=0)
        Interregnum._start(self, **kw)


class Colorado(game.Game):
    """
    Finish 2 deck on foundation using 20 row and waste.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.fortythieves.FortyThievesLayout
        - row [20 over 10 col S foundation,no offset]
        - talon [1 SE, no offset]
        - waste [1 W talon, no offset]
        - foundation [8 horz NE, no offset]

      _talon_ : pysollib.stack.Stack
        .. pysollib.stack.WasteTalon
        Deal 1 card per waste. No redeal.

      _waste_ : pysollib.stack.Stack
        .. pysollib.stack.WasteStack (max_cards=1)
        Init 1 card per. Build none. Play top. Max 1 card.

      _foundation_ : pysollib.stack.Stack
        .. pysollib.foundations.AceKingSS_Foundation (max_move=0)
        Build in rank by same suit. Play top.
          - E 4. Init ace. Build up. Base ace.
          - W 4. Init king. Build down. Base king.

      _row_ : pysollib.stack.Stack
        .. pysollib.stacks.numerica.Colorado_RowStack
        Init 1 card per. Build any from waste. Play top. Gap deal 1 card
        from waste. Max 1 card.

      _hint_ : pysollib.hint.AbstractHint
        .. pysollib.hint.DefaultHint

    :seealso:
      <http://en.wikipedia.org/wiki/Colorado_%28solitaire%29>
    """
    __info__ = dict(id=0x38398, name='Colorado', game_type=GT.NUMERICA,
                    decks=2, skill_level=SL.BALANCED, version='0.80fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _layout_ = FortyThievesLayout.FortyThievesLayout
    _talon_ = stack.WasteTalon
    _waste_ = Wrap(stack.WasteStack, max_cards=1)
    _foundation_ = Wrap(FoundationStack.AceKingSS_Foundation, max_move=0)
    _row_ = NumericaStack.Colorado_RowStack

    def _create_game(self, **kw):
        """
        _create_game([rows=20, ncols=10, playcards=0]) -> Layout

        :returns: current layout with piles and their texts set.

        :seealso: `pysollib.layouts.fortythieves` for keyword definitions.
        """
        kwdefault(kw, rows=20, ncols=2, playcards=0)
        return super(Colorado, self)._create_game(**kw)

    def _pack_place(self, cards):
        """
        _pack_place(cards:seq(Card ...)) -> seq(Card ...)

        Overide to return ACE and KING of suit on top by rank, suit, deck for
        _foundation_ deal.
        """
        return place.MoveToTop(cards, place.OneAceKing)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[foundations] 1 ea.
          - s[rows]: 1 ea.

        .. \_start([]) -> None
        """
        self.s['talon'].dealRow(rows=self.s['foundations'])
        self.s['talon'].dealRow()

    @state.move_state('fill')
    def _auto_fill(self, stack):
        """
        After any play from row, move top waste on row gap.

        *Parameters*:
          stack : pysollib.stack.Stack
            Pile just played.

        *Requires*:
          `pysollib.stackfill.fromWaste` to fill row gap from waste.
        """
        fill.fromWaste(self, stack, self.s['rows'])


PROVIDES = [TamOShanter, AuldLangSyne, Strategy, Interregnum, Colorado,
           Amazons, Acquaintance, Scuffle, DoubleAcquaintance, Primrose,
           StrategyPlus, Formic]